#include "customTagParser.h"

int getNamedAttributes(char *filename,keyvaluecontainer *container)
{
	int i,count = 0;
	char attrName[64] = {'\0'};
	for (i = 0; i < container->numelements; i++)
	{
		sprintf(attrName,"user.%s",container->keyarray[i]);
		container->valuearray[i] = (char *) malloc (sizeof(char) * SMALL_BUFFER_SIZE);
		if (getxattr(filename,attrName,container->valuearray[i],SMALL_BUFFER_SIZE) == -1)
		{
			printf("\nError getting attribute %s: %s",attrName,strerror(errno));
		}
		else
		{
			count++;
		}
	}
	return count;
}
void freeNamedAttributes(keyvaluecontainer *container)
{
	int i = 0;
	for (i = 0; i < container->numelements; i++)
	{
		free(container->valuearray[i]);
		free(container->keyarray[i]);
	}
}
